package com.flowerplus.store.common.structure.ui.activity;

import android.view.View;
import android.widget.LinearLayout;

import com.flowerplus.store.R;
import com.flowerplus.store.common.structure.ui.control.manager.StatusLayoutManager;


/**
 * Created by z on.
 * Des:具有加载状态的activity
 * Date: 2017/3/8
 */

public abstract class LoadingActivity extends BaseActivity {

    //状态管理器
    protected StatusLayoutManager mStatusLayoutManager;

    @Override
    protected int layoutResId() {
        return R.layout.activity_content;
    }

    //初始化状态管理器
    @Override
    protected void initStatus() {
        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.content_layout);
        mStatusLayoutManager = new StatusLayoutManager.Builder(this).contentResId(contentLayout())
                .emptyView(R.layout.layout_empty)
                .errorView(R.layout.layout_error)
                .loadResId(R.layout.layout_loading)
                .netWorkErrorView(R.layout.layout_network_error)
                .retryResId(R.id.rerty)
                .build().setRetryListener(new StatusLayoutManager.RetryListener(){
                    @Override
                    public void retry(View v) {
                        clickRetry(v);
                    }
                }).inject(linearLayout);
    }

    //内容layout id
    protected abstract int contentLayout();

    //重试
    protected abstract void clickRetry(View v);
}
